package org.example.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.example.entity.Article;
import org.example.mapper.ArticleMapper;
import org.example.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public Article get(int id) {
        return articleMapper.get(id);
    }

    @Override
    public PageInfo<Article> etPage(Article article, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Article> page = articleMapper.getPage(article);
        PageInfo<Article> pageInfo = new PageInfo<>(page);
        return pageInfo;
    }

    @Override
    public List<Article> selectArticleById(int id) {
        List<Article> articles = articleMapper.selectArticleById(id);
        return articles;
    }


}
